module gwd_types_mod

  use const_mod
  use static_mod

  implicit none

  ! Statistics of orographic features
  type orog_params_type
    real(r8), allocatable, dimension(:,:,:) :: oa ! Orographic asymmetry
    real(r8), allocatable, dimension(  :,:) :: ol ! Effective orographic length
    real(r8), allocatable, dimension(:,:,:) :: gl ! Model grid length
  contains
    procedure :: init  => orog_params_init
    procedure :: clear => orog_params_clear
    final :: orog_params_final
  end type orog_params_type

contains

  subroutine orog_params_init(this, static)

    class(orog_params_type), intent(inout) :: this
    type(static_type), intent(in) :: static

    call this%clear()

  end subroutine orog_params_init

  subroutine orog_params_clear(this)

    class(orog_params_type), intent(inout) :: this

    if (allocated(this%oa)) deallocate(this%oa)
    if (allocated(this%ol)) deallocate(this%ol)
    if (allocated(this%gl)) deallocate(this%gl)

  end subroutine orog_params_clear

  subroutine orog_params_final(this)

    type(orog_params_type), intent(inout) :: this

    call this%clear()

  end subroutine orog_params_final

end module gwd_types_mod
